<?php
header("Content-Type: text/html; charset=utf-8");
include_once 'link.php';

$action=$_GET['action'];
if($action=="edit"){
	$link_name=$_POST["linkName"];
	$linke_url=$_POST["linkUrl"];
	$link_method=$_POST["linkMethod"];
	$link_picture=$_POST["linkPicture"];
	$id=intval($_POST["proId"]);
	$ret=link_update($id, $link_name, $linke_url, $link_method, $link_picture) ;
	
	if($ret!=true){
		echo "<script>alert('编辑失败！');</script>";	
	}else{
		echo "<script>alert('编辑成功！');</script>";	
	}
	echo ("<script>document.location='linkCatalog.php';</script>");	
}else{
	$id= intval($_GET['id']);
	$catList=get_link_list_by_id($id) ;
	 
	if($catList!=false){
		$catItem=$catList[0];		
	}else{
		 
		die("错误的Id");
	}
}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>菜单分类编辑</title>
<link rel="stylesheet" type="text/css" href="../skin/css/base.css">
<style type="text/css">
.catLog{margin: 20px; padding-top:5px;}
.catLog select { width:300px; }
.catLog input.txtInput{width:300px; }
.catLog input.btSubmit{ margin-left:170px; margin-top:6px;}
</style>
</head>
<body leftmargin="8" topmargin="8" background='../skin/images/allbg.gif'>
<form action="linkEdit.php?action=edit" method="post">
<div class="catLog" >
	 链接名称:&nbsp;<input id="linkName" name="linkName"  class="txtInput" value="<?=$catItem->link_name?>" 
	/><br />
	链接Url:&nbsp;&nbsp;&nbsp;&nbsp;<input id="linkUrl" name="linkUrl"  class="txtInput" value="<?=$catItem->link_url?>" 
	/><br />
	  链接方法:&nbsp;<input id="linkMethod" name="linkMethod"  class="txtInput" value="<?=$catItem->link_method?>" 
	/><br />
	 链接图片:&nbsp;<input id="linkPicture" name="linkPicture"  class="txtInput" value="<?=$catItem->link_picture?>" 
	/><br />
<input type="submit" class="btSubmit" value="提交" /> <br />
<input type="hidden" value="<?=$_GET["id"]?>" name="proId" id="proId" />
</div>
</form>
</body>
</html>
